#include<AnalysisTools/TTruthUtils.hxx>
#include</home/smithr/nd2805C/fluxweight.hxx>

class fluxweight{
public:
float fweight(TClonesArray *vtxs, int NVtx, float vid, TH1F *fnumu, TH1F *fnumub, TH1F *fnue, TH1F *fnueb){
  for(int count = 0; count < NVtx; ++count){
    ND::TTruthVerticesModule::TTruthVertex *vtxTest = (ND::TTruthVerticesModule::TTruthVertex*)(*vtxs)[count];
    if(vtxTest->ID == vid){ 
      if(vtxTest->NeutrinoPDG ==   12){
        histbin = fnue->FindBin((vtxTest->NeutrinoMomentum.E()/1000.0));
        testvar = fnue->GetBinContent(histbin);
        }
      if(vtxTest->NeutrinoPDG ==  -12){
        histbin = fnueb->FindBin((vtxTest->NeutrinoMomentum.E()/1000.0));
        testvar = fnueb->GetBinContent(histbin);
        }
      if(vtxTest->NeutrinoPDG ==   14){
        histbin = fnumu->FindBin((vtxTest->NeutrinoMomentum.E()/1000.0));
        testvar = fnumu->GetBinContent(histbin);
        }
      if(vtxTest->NeutrinoPDG ==  -14){
        histbin = fnumub->FindBin((vtxTest->NeutrinoMomentum.E()/1000.0));
        testvar = fnumub->GetBinContent(histbin);
        }
      }
    }
  return testvar;  
  }
  
float bincont(TH1F *hist,float value){
  hbin    = hist->FindBin(value);
  return hbin;
  }
  
float binvalue(TH1F *hist,float weight,int hibin){ 
  newcont = weight+hist->GetBinContent(hibin);
  return newcont;
  }
};
